package com.ffmpeg.util.infra.handle.file;

import java.io.File;

import com.ffmpeg.util.infra.constant.DealWhenExistEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author :wm
 * @description : 当目标文件存在时抛出异常
 */
@Component
public class ThrowWhenExistHandle implements IDealWhenExistHandle {
    private final static Logger logger = LoggerFactory.getLogger(ThrowWhenExistHandle.class);

    @Override
    public String executeFileWhenExist(String filePath) {
        File file = new File(filePath);
        Assert.isTrue(file.exists(), "error.file.exist");
        return filePath;
    }

    @Override
    public DealWhenExistEnum getType() {
        return DealWhenExistEnum.THROW_ERROR;
    }
}
